#include "sensornode.h"
#include "iot_debug.h"

SensorNode::SensorNode()
{

}

SensorNode::~SensorNode()
{

}

bool SensorNode::addAttr(const std::string &name, const RegBase *reg)
{
    auto it = attrs_.find(name);
    if (it != attrs_.end())
        return false;

    attrs_[name] = reg;
    return true;
}

const RegBase* SensorNode::findReg(const std::string &name)
{
    auto it = attrs_.find(name);
    if (it != attrs_.end())
        return it->second;

    return NULL;
}

bool SensorNode::addYkList(const std::string &name, const std::string &regname)
{
    auto it = yklist_.find(name);
    if (it != yklist_.end())
        return false;

    yklist_[name] = regname;
    return true;
}

const std::string SensorNode::findYkregname(const std::string &name) const
{
    auto it = yklist_.find(name);
    if (it != yklist_.end())
        return it->second;
    return "";
}
